package common
{
    import flash.display.Sprite;
    import flash.events.Event;
    
    import kernel.application.ApplicationDisplay;
    import kernel.core.Core;
    import kernel.core.EnterFrameEventManager;
    import kernel.moduleManager.LoadModuleManager;

    public class AppLayers
    {
        private static var _instance:AppLayers;
		
        private var _maxInitNum:uint;
        private var _minInitNum:uint;
        private var _componentInitIndex:uint;

        private var _isResetting:Boolean;
        private var _willRest:Boolean;
        private var _resetMap:Object;
        private var _numResetComponents:uint;

        private var _backLayer:Sprite;
        private var _foreLayer:Sprite;
        private var _lockMouseLayer:Sprite;
        //		private var _guestLayer:Sprite;
        private var _middleLayer:Sprite;
        private var _fightLayer:Sprite;
        private var _topLayer:Sprite;
        private var _alertLayer:Sprite;
        private var _screenMiddleMotionLayer:Sprite;
        private var _photoLayer:Sprite;
        private var _helpLayer:Sprite;
        private var _mouseLayer:Sprite;
		
		private static var _popWindowLayer:Sprite;
		
		private static var _noticeLayer:Sprite = new Sprite();
		private static var _topToolLayer:Sprite = new Sprite();

        private var _view:Sprite;


        public function AppLayers()
        {
            _constructor ();
        }

		public static function get topToolLayer():Sprite
		{
			return _topToolLayer;
		}

		public static function get popWindowLayer():Sprite
		{
			return _popWindowLayer;
		}

		public static function get noticeLayer():Sprite
		{
			return _noticeLayer;
		}

        public static function get instance():AppLayers
        {
			if(_instance==null)
			{
				_instance = new AppLayers();
			}
            return _instance;
        }
		
		public static function init():void
		{
			_instance = new AppLayers();
		}

        private function _constructor():void
        {
            _view = new Sprite ();
            _view.mouseEnabled = false;
            _backLayer = new Sprite ();
            _middleLayer = new Sprite ();
            _foreLayer = new Sprite ();
            _alertLayer = new Sprite ();
            _fightLayer = new Sprite ();
            _topLayer = new Sprite ();
			_popWindowLayer = new Sprite();
            _screenMiddleMotionLayer = new Sprite ();
            _photoLayer = new Sprite ();
            //			_guestLayer=new Sprite();
            //			_guestLayer.mouseEnabled = false;
            _helpLayer = new Sprite ();
            _mouseLayer = new Sprite ();
			_helpLayer.mouseEnabled = false;
            _mouseLayer.mouseChildren = false;
            _mouseLayer.mouseEnabled = false;
			_popWindowLayer.mouseEnabled = false;
			_noticeLayer.mouseEnabled = false;
			_topToolLayer.mouseEnabled = false;
			_backLayer.mouseEnabled = false;
			_middleLayer.mouseEnabled = false;
			_foreLayer.mouseEnabled = false;
			_alertLayer.mouseEnabled = false;
			_fightLayer.mouseEnabled = false;
			_topLayer.mouseEnabled = false;
			_photoLayer.mouseEnabled = false;
			_screenMiddleMotionLayer.mouseChildren = false;
			_screenMiddleMotionLayer.mouseEnabled = false;
			
			_view.visible = false;
			Core.stage.addChild (_backLayer);
//           _view.addChild(_guestLayer);
			Core.stage.addChild (_middleLayer);
			Core.stage.addChild (_foreLayer);
			Core.stage.addChild (_fightLayer);
			Core.stage.addChild (_topLayer);
			Core.stage.addChild (_alertLayer);
			Core.stage.addChild (_screenMiddleMotionLayer);
			Core.stage.addChild (_photoLayer);
			Core.stage.addChild (_helpLayer);
			Core.stage.addChild (_mouseLayer);
			Core.stage.addChild(LoadModuleManager.modulesLayer);
			Core.stage.addChild(_topToolLayer);
			Core.stage.addChild(_popWindowLayer);
			Core.stage.addChild(_noticeLayer);
			

//			Core.addEnterFrameListener(test);
        }
		private function test(event:Event):void
		{
			trace(Core.stage.align,_view.x,_view.y,LoadModuleManager.modulesLayer.x,LoadModuleManager.modulesLayer.y);
		}

        public function get fightLayer():Sprite
        {
            return _fightLayer;
        }

        public function get backLayer():Sprite
        {
            return _backLayer;
        }

        public function get topLayer():Sprite
        {
            return _topLayer;
        }

        public function get foreLayer():Sprite
        {
            return _foreLayer;
        }

        public function get middleLayer():Sprite
        {
            return _middleLayer;
        }

        //		public function get guestLayer():Sprite {
        //			return _guestLayer;
        //		}
        public function get screenMiddleMotionLayer():Sprite
        {
            return _screenMiddleMotionLayer;
        }

        public function get photoLayer():Sprite
        {
            return _photoLayer;
        }

        public function get alertLayer():Sprite
        {
            return _alertLayer;
        }

        public function get helpLayer():Sprite
        {
            return _helpLayer;
        }

        public function get mouseLayer():Sprite
        {
            return _mouseLayer;
        }

        public function get view():Sprite
        {
            return _view;
        }
    }
}
